package com.content_module.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.content_module.R;
import com.lzy.imagepicker.bean.ImageItem;

import java.io.File;

import component.fy.com.common_module.baseAdapter.BaseRecyclerAdapter;
import component.fy.com.common_module.baseAdapter.BaseViewHolder;
import component.fy.com.common_module.utils.GlideUtils;
import component.fy.com.common_module.widget.GlideRoundTransform;

public class ImagePickerAdapter extends BaseRecyclerAdapter<ImageItem> {

    public ImagePickerAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }

    @Override
    public void onBind(BaseViewHolder holder, @Nullable ImageItem bean, int position) {
        ImageView imageView = holder.getView(R.id.content_item_image_img);
        if (position == 0) {
            GlideUtils.setImageNormal(getContext(), R.mipmap.ic_launcher, imageView);
        } else {
            File file = new File(bean.path);
            Glide.with(getContext())
                    .load(file)
                    .asBitmap()
//                    .transform(new GlideRoundTransform(getContext(), 5))
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .into(imageView);
        }
    }
}
